package com.acme.bankapp.domain.bank;

import com.acme.exceptions.*;

public class SavingsAccount extends AbstractAccount {
  private double balance;
  
  public SavingsAccount(double balance){
    this.balance = balance;
  }
  
  @Override
  public void deposit(double x) throws IllegalArgumentException {
    if(x <0.0){
      throw new IllegalArgumentException();
    }
    this.balance +=x;
  }

  @Override
  public void withdraw(double x) throws IllegalArgumentException, 
                       NotEnoughFundsException{
    if(x <0.0){
      throw new IllegalArgumentException();
    }
    if(x>balance){
      throw new NotEnoughFundsException();
    }
    this.balance -=x;
  }
  
  @Override
  public double maximumAmountToWithdraw(){
    return balance;
  }
  
  @Override
  public double getBalance(){
    return this.balance;
  }
}
